/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main.social.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author user
 */
@Entity
@Table(name = "users")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
    @NamedQuery(name = "Users.findById", query = "SELECT u FROM Users u WHERE u.id = :id"),
    @NamedQuery(name = "Users.findByName", query = "SELECT u FROM Users u WHERE u.name = :name"),
    @NamedQuery(name = "Users.findByAvatar", query = "SELECT u FROM Users u WHERE u.avatar = :avatar"),
    @NamedQuery(name = "Users.findByBackground", query = "SELECT u FROM Users u WHERE u.background = :background"),
    @NamedQuery(name = "Users.findByBirth", query = "SELECT u FROM Users u WHERE u.birth = :birth"),
    @NamedQuery(name = "Users.findByGender", query = "SELECT u FROM Users u WHERE u.gender = :gender")})
public class Users implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "name", nullable = false, length = 100)
    private String name;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Column(name = "avatar", length = 100)
    private String avatar;
    @Column(name = "background", length = 100)
    private String background;
    @Column(name = "birth")
    @Temporal(TemporalType.DATE)
    private Date birth;
    @Column(name = "gender", length = 20)
    private String gender;
    @Lob
    @Column(name = "description", length = 2147483647)
    private String description;
    @JoinTable(name = "users_has_schools", joinColumns = {
        @JoinColumn(name = "Users_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "Schools_id", referencedColumnName = "id")})
    @ManyToMany
    private List<Schools> schoolsList;
    @JoinTable(name = "users_has_jobs", joinColumns = {
        @JoinColumn(name = "Users_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "Jobs_id", referencedColumnName = "id")})
    @ManyToMany
    private List<Jobs> jobsList;
    @JoinColumn(name = "Address_id", referencedColumnName = "id")
    @ManyToOne
    private Address addressid;
    @JoinColumn(name = "Accounts_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Accounts account;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "users")
    private List<Friends> friendsList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "users1")
    private List<Friends> friendsList1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
    private List<Entrys> entrysList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersid")
    private List<Entrylike> entrylikeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersid")
    private List<Entrytag> entrytagList;

    public Users() {
    }

    public Users(Long id) {
        this.id = id;
    }

    public Users(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    @SuppressWarnings("unused")
	private void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getBackground() {
        return background;
    }

    public void setBackground(String background) {
        this.background = background;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<Schools> getSchoolsList() {
        return schoolsList;
    }

    public void setSchoolsList(List<Schools> schoolsList) {
        this.schoolsList = schoolsList;
    }

    @XmlTransient
    public List<Jobs> getJobsList() {
        return jobsList;
    }

    public void setJobsList(List<Jobs> jobsList) {
        this.jobsList = jobsList;
    }

    public Address getAddressid() {
        return addressid;
    }

    public void setAddressid(Address addressid) {
        this.addressid = addressid;
    }

    public Accounts getAccount() {
        return account;
    }

    public void setAccount(Accounts account) {
        this.account = account;
    }

    @XmlTransient
    public List<Friends> getFriendsList() {
        return friendsList;
    }

    public void setFriendsList(List<Friends> friendsList) {
        this.friendsList = friendsList;
    }

    @XmlTransient
    public List<Friends> getFriendsList1() {
        return friendsList1;
    }

    public void setFriendsList1(List<Friends> friendsList1) {
        this.friendsList1 = friendsList1;
    }

    @XmlTransient
    public List<Entrys> getEntrysList() {
        return entrysList;
    }

    public void setEntrysList(List<Entrys> entrysList) {
        this.entrysList = entrysList;
    }

    @XmlTransient
    public List<Entrylike> getEntrylikeList() {
        return entrylikeList;
    }

    public void setEntrylikeList(List<Entrylike> entrylikeList) {
        this.entrylikeList = entrylikeList;
    }

    @XmlTransient
    public List<Entrytag> getEntrytagList() {
        return entrytagList;
    }

    public void setEntrytagList(List<Entrytag> entrytagList) {
        this.entrytagList = entrytagList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Users)) {
            return false;
        }
        Users other = (Users) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "main.social.entity.Users[ id=" + id + " ]";
    }
    
}
